<?php

/**
 *      [Hero! Cms] (C)2011-2012.
 *
 *      $Id: admin.php 28 2011-08-17 12:07:22Z zyb0807@gmail.com $
 */

define('IN_ADMINCP', TRUE);
define('NOROBOT', TRUE);
define('ADMINSCRIPT', basename(__FILE__));
define('CURSCRIPT', 'admin');
define('APPTYPEID', 0);

require './source/class/class_core.php';
require './source/class/class_admincp.php';
//require './source/function/function_misc.php';
require './source/function/function_admincp.php';
require './source/function/function_cache.php';

$hero = & hero_core::instance();
$hero->init();
$admincp = new hero_admincp();
$admincp->core  = & $hero;
$admincp->init();

//echo '<pre>';
//print_r($hero);
//exit;
//echo '<pre>';
//echo '<h1>2. hero_admincp class</h1>';
//print_r($admincp);
$admincp_actions_founder = array('db', 'founder');
$admincp_actions_normal = array('index', 'member', 'log', 'module', 'memberprofile', 'credit');

$action = getgpc('action');
$operation = getgpc('operation');
$do = getgpc('do');
$frames = getgpc('frames');
$lang = lang('admincp');
$page = max(1, intval(getgpc('page')));
$isfounder = $admincp->isfounder;

if(empty($action) || $frames != null) {
	$admincp->show_admincp_main();
} elseif($action == 'logout') {
	$admincp->do_admin_logout();
	dheader("Location: ./admin.php");
} elseif(in_array($action, $admincp_actions_normal) || ($admincp->isfounder && in_array($action, $admincp_actions_founder))) {
	if($admincp->allow($action, $operation, $do) || $action == 'index') {
		require $admincp->admincpfile($action);
	} else {
		cpheader();
		cpmsg('action_noaccess', '', 'error');
	}
} else {
	cpheader();
	cpmsg('action_noaccess', '', 'error');
}


?>
